function van3

global lam

figure(1)
clf
% get(gcf)
set(gcf,'Position', [25 1028 560 309])
co = [0 0 1;
    0 0.5 0;
    1 0 0;
    0 0.75 0.75;
    0.75 0 0.75;
    0.75 0.75 0;
    0.25 0.25 0.25];
set(groot,'defaultAxesColorOrder',co)
subaxis(1,1,1,1,'MT',0.01,'MB',0.2,'MR',0.01,'ML',0.05,'P',0.04)

hold on
%axis equal
nx=100; ym=3;
ys=linspace(-ym,ym,nx);
for i=1:nx
    vs(i)=(ys(i)-ys(i)^3/3);
end

axis([-2.1 2.1 -1 1])

ep=0.1
lam=1/ep
tmax=2*pi;
y10=sqrt(3); y20=0;
y0=[y10 y20];
% calculate solution using a MATLAB routine
options = odeset('RelTol', 1e-6,'AbsTol',1e-6);
[t,y] = ode45(@rhs,[0 tmax],y0,options);


ep=0.01
lam=1/ep
tmax=5*pi;
y10=sqrt(3); y20=0;
y0=[y10 y20];
% calculate solution using a MATLAB routine
options = odeset('RelTol', 1e-6,'AbsTol',1e-6);
[t2,y2] = ode45(@rhs,[0 tmax],y0,options);

hold on
plot(y(:,1),y(:,2),'b','LineWidth',1.5)
plot(y2(:,1),y2(:,2),'r','LineWidth',1.5)
%plot(y2(1,1),y2(1,2),'.b','MarkerSize',20)

legend({' $\varepsilon = 0.1$',' $\varepsilon = 0.01$'},'Position',[0.245 0.56 0.22 0.16],'interpreter','latex','AutoUpdate','off')

% commands to label each axes
xlabel('y-axis','FontWeight','bold')
ylabel('u-axis','FontWeight','bold')
grid on

box on
set(gca,'FontSize',16)
plot(ys,vs,'k','LineWidth',1)

hold off

exportgraphics(gcf,'/Users/mark/Desktop/van3.pdf')

return

figure(2)
clf
% get(gcf)
set(gcf,'Position', [26 695 563 249])
co = [0 0 1;
    0 0.5 0;
    1 0 0;
    0 0.75 0.75;
    0.75 0 0.75;
    0.75 0.75 0;
    0.25 0.25 0.25];
set(groot,'defaultAxesColorOrder',co)
subaxis(1,1,1,1,'MT',0.01,'MB',0.2,'MR',0.01,'ML',0.05,'P',0.04)

hold on
plot(t2,y2(:,1),'b','LineWidth',1.5)
%plot(tl,yl(:,2),'r')
axis([0 6 -2.1 2.1])
xlabel('\tau-axis','FontWeight','bold')
ylabel('y-axis','FontWeight','bold')
grid on
text(4.1,0,'A','FontSize',14,'FontWeight','bold')
text(2.8,-1.8,'B','FontSize',14,'FontWeight','bold')
text(3.2,0,'C','FontSize',14,'FontWeight','bold')
text(3.7,1.8,'D','FontSize',14,'FontWeight','bold')
set(gca,'FontSize',16)

exportgraphics(gcf,'/Users/mark/Desktop/van2.pdf')

figure(3)
clf
% get(gcf)
set(gcf,'Position', [26 695 563 249])
co = [0 0 1;
    0 0.5 0;
    1 0 0;
    0 0.75 0.75;
    0.75 0 0.75;
    0.75 0.75 0;
    0.25 0.25 0.25];
set(groot,'defaultAxesColorOrder',co)
subaxis(1,1,1,1,'MT',0.01,'MB',0.2,'MR',0.01,'ML',0.05,'P',0.04)

hold on
plot(t2,y2(:,2),'b','LineWidth',1.5)
y2(1,2)
y2(2,2)
axis([0 6 -1 1])
xlabel('\tau-axis','FontWeight','bold')
ylabel('u-axis','FontWeight','bold')
grid on
set(gca,'FontSize',16)


%  define f(t,y)
function dy=rhs(t,y)
global lam
dy=zeros(2,1);
dy(1) = lam^2*(y(1)*(1-y(1)^2/3)-y(2));
dy(2) = y(1);

% function z=dY(y,u)
% global lam
% z = lam^2*(y*(1-y^2/3)-u);
% 
% function z=dU(y,u)
% global lam
% z = y;






